//
//  MyViewController.m
//  BrushFace
//
//  Created by timer_q on 15/12/4.
//  Copyright © 2015年 Zzz. All rights reserved.
//

#import "MyViewController.h"
#import "MyHeaderView.h"
#import "MyAssetsCell.h"
#import "MyDefaultCell.h"
#import "MyCreditCell.h"

@interface MyViewController ()<UITableViewDelegate,UITableViewDataSource>
{
    NSMutableArray *_dataArray;
}
@property (strong, nonatomic)UITableView *tableView;
@end

@implementation MyViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    [self UIConfig];
    [self dataInit];
}
- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    self.tabBarController.tabBar.hidden = NO;
    self.navigationController.navigationBar.hidden = YES;
    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
}
- (void)viewDidDisappear:(BOOL)animated{
    [super viewDidDisappear:animated];
    self.navigationController.navigationBar.hidden = NO;
}

#pragma mark - data
- (void)dataInit{
    _dataArray = [[NSMutableArray alloc] initWithObjects:@"",@"",@"",@"",@"", nil];
   
    [_tableView reloadData];
}

#pragma mark - customUI
- (void)UIConfig{
    _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, -20, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height-20)];
    _tableView.delegate = self;
    _tableView.dataSource = self;
    _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    _tableView.backgroundColor = UIColorFromRGB(0xefeff4);
    _tableView.showsVerticalScrollIndicator = NO;
    MyHeaderView *headerView = [MyHeaderView loadBundleNib];
    headerView.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.width*0.66);
    _tableView.tableHeaderView = headerView;
    [self.view addSubview:_tableView];
}


#pragma mark - tableViewDelegate and DataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return _dataArray.count;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 1;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section == 1) {
        return 160;
    }
    return 44;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 10;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *MyAssetsCellId = @"MyAssetsCell";
    static NSString *MyDefaultCellId = @"MyDefaultCell";
    static NSString *MyCreditCellId = @"MyCreditCell";
    
    
    if (indexPath.section == 0) {
        MyCreditCell *cell = [tableView dequeueReusableCellWithIdentifier:MyCreditCellId];
        if (cell == nil) {
            cell = [MyCreditCell loadBundleNib];
        }
        return cell;
    }else if(indexPath.section == 1){
        MyAssetsCell *cell = [tableView dequeueReusableCellWithIdentifier:MyAssetsCellId];
        if (cell == nil) {
            cell = [MyAssetsCell loadBundleNib];
        }
        return cell;
    }else{
        MyDefaultCell *cell = [tableView dequeueReusableCellWithIdentifier:MyDefaultCellId];
        if (cell == nil) {
            cell = [MyDefaultCell loadBundleNib];
        }
        return cell;
    }
    return nil;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
